package gamecomponents;

import java.io.Serializable;

/**
 * A post in a leaderboard.
 * @author Team Deer
 * 
 */
public class LeaderboardComponent implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 6771764027926735176L;
	
	private final Time time;
	private final String name;

	// Constructor
	
	/**
	 * Constructs a new LeaderboardComponent.
	 * @param timeOfRun
	 *            - the time of one game
	 * @param name
	 *            - the name of the user
	 */
	public LeaderboardComponent(final Time timeOfRun, final String name) {
		this.time = timeOfRun;
		this.name = name;
	}
	
	// Methods
	
	/**
	 * Gets the time of this leaderboard post. 
	 * @return the time
	 */
	public Time getTime(){
		return this.time;
	}
	
	/**
	 * Used by Leaderboard to draw itself as a Texture.
	 * 
	 * @return a formated string with name, time and date
	 */
	public String toFormattedString() {
		final String output = this.name + "; \t" + this.time.getHours() + ":"
				+ this.time.getMinutes() + ":" + this.time.getSeconds() + ":"
				+ this.time.getMilliSeconds() + "; \t" + this.time.dateToString();
		return output;
	}

}
